package com.circus.trace.biz.product;

import java.util.List;

import org.nutz.dao.Cnd;
import org.nutz.lang.ContinueLoop;
import org.nutz.lang.Each;
import org.nutz.lang.ExitLoop;
import org.nutz.lang.Lang;
import org.nutz.lang.LoopException;
import org.nutz.plugin.spring.boot.service.BaseService;
import org.springframework.stereotype.Service;

import com.circus.trace.bean.product.ProductCoffee;
import com.google.common.collect.Lists;

@Service
public class ProductCoffeeService extends BaseService<ProductCoffee> {

    public List<Long> coffeeIds(long productId) {
        List<Long> target = Lists.newArrayList();
        Lang.each(query(Cnd.where("productId", "=", productId)), new Each<ProductCoffee>() {

            @Override
            public void invoke(int index, ProductCoffee ele, int length) throws ExitLoop, ContinueLoop, LoopException {
                target.add(ele.getCoffeeId());
            }
        });
        return target;
    }

}
